home *** CD-ROM | disk | FTP | other *** search
/ Commodore Free 10 / Commodore_Free_Issue_10_2007_Commodore_Computer_Club.d64 / t.slang ref < prev    next >
Text File  |  2023-02-26  |  2KB  |  145 lines

  1. u     Slang Quick Reference guide
  2.  
  3. Numbers and misc
  4.  
  5. ; ;comment
  6.  
  7.  
  8. * ;comment when in 1st column
  9. a=1234 ;base 10
  10. a=$1234 ;base 16
  11. a=%11010 ;base
  12. 2
  13.  
  14. a=a + & ;line continuation
  15.  
  16. b
  17. a$="Howdy" ;strings -- " or ' allowed
  18. delimeters
  19. a$=!5"hola"!13 ;like
  20. chr$(5)+"hola"+chr$(13)
  21. a$=!s"hey" ;!s -- use screen codes
  22. instead of petscii
  23.  
  24. ;!r v use regular (petscii) codes
  25. ;!n v negate (ora $80) following
  26. codes
  27. ;!z v do not null-terminate string
  28.  
  29. Slang is CaSe InSeNsItIvE
  30.  
  31. Variable types and declarations
  32.  
  33. byte, ubyte ;1 byte, signed/unsigned
  34. int, uint ;2 bytes, signed/unsigned
  35. float ;5 bytes, MFLPT format
  36.  
  37. byte blah@$d020 ;@-var: locate
  38. variable at $d020
  39.  
  40. int screen(25,40)@$0400 ;Create 2D
  41. array, locate at text screen
  42. int blah(3,3)=[ [1 2 3]
  43. &
  44.  
  45. [4 5 6]
  46. &
  47. [7 8 9] ] ;Create 2D array and
  48. pre-initialize values
  49. ubyte str(50)=['..can also use strings
  50. to pre-initialize'
  51. ]
  52. blah(2,0) = 1 ;Note that array indices
  53. start at
  54. 0
  55.  
  56. byte ^test ;Create 16-bit pointer to a
  57. byte
  58. byte ^^test2(20,10) ;24-bit pointer to
  59. byte array
  60. test=$c000 ;set point location: lda
  61. #$c000 sta zp
  62. ^test=10 ;set location value: lda #10
  63. sta (zp),
  64. y
  65. test2=$123456 ;set array base address
  66. test2(3,5)=10 ;leading ^ not used with
  67. arrays
  68.  
  69.  
  70. deftype foo ;Compound variable type
  71. declaration
  72. int .a ;note leading
  73. .
  74. byte .b(10)
  75. float .
  76. x
  77.  
  78.  
  79. defend
  80.  
  81.  
  82. type foo yak1, yak2 ;Create two
  83. variables of compound type foo
  84. yak1.a = 10 ;...which can then access
  85. individual elements
  86. yak.b(3) = -
  87. 8
  88. yak1.x = 3.1415926
  89.  
  90.  
  91. VarBlock @$c000 ;Define following
  92. variables starting at $c000
  93. ubyte t1
  94. int t2
  95.  
  96.  
  97. EndVarBlock ;until the EndVarBlock
  98.  
  99.  
  100. int b,
  101. c
  102. c=#b+3 ;Set c to the DaddressD of b
  103. plus three
  104.  
  105.  
  106. Strings
  107.  
  108.  
  109. byte str(20) ;Strings are byte arrays,
  110. null-terminated
  111. str(1) = 1 ;Treat as byte array
  112. str$="Hey!!"!13 ;Using the $ sign
  113. treats as string
  114.  
  115.  
  116. if str$(2:4) = "y!!" ;Can specify
  117. substring ranges
  118. str$(2)="blah" ;{SHIFT--}H{SHIFT--}e{SHIFT--}b{SHIFT--}l{SHIFT--}a{SHIFT--}h{SHIFT--}00
  119. Subroutines
  120.  
  121.  
  122. note: <- indicates backarrow key; use
  123. D (underscore) on PC/xlang
  124.  
  125.  
  126. sub blah() ;Subroutine with no input
  127. or output variables
  128. sub blah2(int x, byte r) ;Subroutine
  129. with two input variables
  130. sub blah3(int z)<-byte s,int t
  131. ;Subroutine with one input variable
  132. (z)
  133.  
  134.  
  135. ;and two output variables (s, t)
  136.  
  137.  
  138. sub blah4(@ax) ;One input variable, in
  139. the .A (lo) and .X (hi)
  140. ;registers. @x @a @xy @yx ->
  141.  
  142.  
  143.  
  144. ...end...
  145.  
  146.